import Stack from "./stack";

// 十进制转二进制
const dec2bin = (num) => {
  let rem = 0;
  let str = "";
  const stack = new Stack();

  while (num > 0) {
    rem = num % 2;
    stack.push(rem);
    num = Math.floor(num / 2);
  }

  while (!stack.isEmpty()) {
    str += stack.pop();
  }

  return str
};

export default dec2bin